var userid="";
usersAdmin();

var iss=getvl("iss");//直播传入过来的
    $(function(){
    	if(iss==1){
    		$("#idss").html("");
    	  	var shopidss='<span>已选择<em id="xuanzhejianshu"></em>件</span>'+
		'<input type="button" onclick="zhiboqueren()" value="确定" />';
			$("#idss").append(shopidss);
    	}else if(iss==2){
    		$("#idss").html("");
    	  	var shopidss='<span>已选择<em id="xuanzhejianshu"></em>件</span>'+
		'<input type="button" onclick="zhiboqueren2()" value="确定" />';
			$("#idss").append(shopidss);
    	}else if(iss==3){
    		$("#idss").html("");
    	  	var shopidss='<span>已选择<em id="xuanzhejianshu"></em>件</span>'+
		'<input type="button" onclick="zhiboqueren3()" value="确定" />';
			$("#idss").append(shopidss);
    	}else if(iss==4){
    		$("#idss").html("");
    	  	var shopidss='<span>已选择<em id="xuanzhejianshu"></em>件</span>'+
		'<input type="button" onclick="zhiboqueren4()" value="确定" />';
			$("#idss").append(shopidss);
    	}else if(iss==5){
    		$("#idss").html("");
    	  	var shopidss='<span>已选择<em id="xuanzhejianshu"></em>件</span>'+
		'<input type="button" onclick="zhiboqueren5()" value="确定" />';
			$("#idss").append(shopidss);
    	}else if(iss==6){
    		$("#idss").html("");
    	  	var shopidss='<span>已选择<em id="xuanzhejianshu"></em>件</span>'+
		'<input type="button" onclick="zhiboqueren6()" value="确定" />';
			$("#idss").append(shopidss);
    	}else if(iss==7){
    		$("#idss").html("");
    	  	var shopidss='<span>已选择<em id="xuanzhejianshu"></em>件</span>'+
		'<input type="button" onclick="zhiboqueren7()" value="确定" />';
			$("#idss").append(shopidss);
    	}else if(iss==8){
    			var shopidss='<span>已选择<em id="xuanzhejianshu"></em>件</span>'+
		'<input type="button" onclick="zhiboqueren8()" value="确定" />';
			$("#idss").append(shopidss);
    	}
    });
    
    var shopid="";
function shop(id){
    	 $.ajax({
      url: urlcore + "/api/shopInfo/selectagno1?id="+id,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					shopid=data.data.id;
					shangquan();
			}
			},
			error: function() {
				alert("error");
			}
		});	
}

function usersAdmin(){
	     
    	 $.ajax({
      url: urlcore + "/api/login/selectLoginUser",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					shop(data.data.id);
					userid=data.data.id;
					//alert(data.data.id);
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "../1.0.0denglu.html";
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}
			},
			error: function() {
				alert("error");
			}
		});	
    
}



var sun=1;
var currentPage=1;
var ss=0;
    function shangquan(){
            if(currentPage==1 || ss!=0){
    	  if(shopid!=""){
    	 $.ajax({
      url: urlcore + "/api/goods/selectGoodsList?current="+currentPage+"&shopId="+shopid,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					
					ss=data.data.list.length;
					$.each(data.data.list, function(y,n) {
		var shangpingxuanzhe='<div class="clearfix add_goods">'+
'		<div class="public-xuanze fl" onclick="dianji('+n.id+')">'+
'			<input type="checkbox" id="checkbox-1-'+sun+'" value="'+n.id+'" name="test" class="regular-checkbox" />'+
'			<label for="checkbox-1-'+sun+'"></label>'+
'		</div>'+
'		<div class="clearfix tuwen">'+
'	    	<a href="javascript:void(0);">'+
'		        <div class="tuwen-img fl">'+
'		            <img onerror="errorImg(this)" src="'+n.coverUrl+'" width="75" height="75">'+
'		        </div>'+
'		        <div class="tuwen-wenzi">'+
'		            <h5 class="wuye_h01">'+n.goodsTitle+'</h5>'+
'		            <div class="wuye_div02">&yen;'+n.packPrice+'</div>'+
'		        </div>'+
'	        </a>'+
'	    </div>'+
'	</div>';
               sun++;
               $("#shangpingxuanzhe").append(shangpingxuanzhe);
					});
					
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}
			},
			error: function() {
				alert("error");
			}
		});	
		 }
    	 }
    }
    

function queren(){
	    var chanshu=$("#chanhsu").val();
	    	//alert("确认"+chanshu);
	    	window.location.href = "../4.5.2weihuo_fabu.html?chanshu="+chanshu+"&userid="+userid;
}


function zhiboqueren(){
	 var chanshu=$("#chanhsu").val();
	    	//alert("确认"+chanshu);
	 window.location.href = "22.1.1huodong_zhibo_shenqing.html?chanshu="+chanshu+"&id="+userid;
}
function zhiboqueren8(){
	 var chanshu=$("#chanhsu").val();
	    	//alert("确认"+chanshu);
	 window.location.href = "22.4.1huodong_xinpin_shenqing.html?chanshu="+chanshu+"&id="+userid;
}


function zhiboqueren2(){
	 var chanshu=$("#chanhsu").val();
	//alert("确认"+chanshu);
	 window.location.href = "22.2.1huodong_xianshi_shenqing.html?chanshu="+chanshu+"&id="+userid;
}


function zhiboqueren3(){
	 var chanshu=$("#chanhsu").val();
	//alert("确认"+chanshu);
	 window.location.href = "22.5.1huodong_pingtai_shenqing.html?chanshu="+chanshu+"&id="+userid;
}

function zhiboqueren4(){
	 var chanshu=$("#chanhsu").val();
	//alert("确认"+chanshu);
	 window.location.href = "22.6.1huodong_qitian_shenqing.html?chanshu="+chanshu+"&id="+userid;
}

function zhiboqueren5(){
	 var chanshu=$("#chanhsu").val();
	//alert("确认"+chanshu);
	 window.location.href = "22.7.1huodong_yijian_shenqing.html?chanshu="+chanshu+"&id="+userid;
}


function zhiboqueren6(){
	 var chanshu=$("#chanhsu").val();
	//alert("确认"+chanshu);
	 window.location.href = "20.4.0zidongtuijian.html?chanshu="+chanshu+"&id="+userid;
}


function zhiboqueren7(){
	 var chanshu=$("#chanhsu").val();
	 window.location.href = "20.5.0simizhibo.html?chanshu="+chanshu+"&id="+userid;
}
